<script type="text/javascript">
    function checkAllList(){
       var theform = document.frmForm;
       var n = parseInt(theform.iCount.value);

       for(i=0; i<n; i++){
           if(theform.checkAll.checked){
           	  	document.getElementById("checkItem"+i).checked=true;
           }else{
           		document.getElementById("checkItem"+i).checked=false;
           }
       }
       return true;
    }

    function search(){
    	var theform = document.frmForm;
    	theform.submit();
    	return true;
    }

    function deleteAction(value){
    	var theform = document.frmForm;
    	theform.idValue.value = value;
    	theform.action = "<{$APPLICATION_URL}>/Admin/User/delete";
    	theform.submit();
    	return true;
    }


    function resendPassAction(value){
    	var theform = document.frmForm;
    	theform.idValue.value = value;
    	theform.action = "<{$APPLICATION_URL}>/Admin/User/resendPass";
    	theform.submit();
    	//alert ("123");
    	return true;
    }
	
	function resendActivateCode(value){
    	var theform = document.frmForm;
    	theform.idValue.value = value;
    	theform.action = "<{$APPLICATION_URL}>/Admin/User/resendActCode";
    	theform.submit();
    	return true;
    }
	
	function loginUserAction(value){
    	var theform = document.frmForm;
    	theform.idValue.value = value;
    	theform.action = "<{$APPLICATION_URL}>/Admin/User/loginUser";
    	theform.submit();
    	return true;
    }
</script>
<form method="post" action="<{$APPLICATION_URL}>/Admin/User/index" name = "frmForm">
<a href="<{$APPLICATION_URL}>/Admin/User/add">Create a new user</a>
<div class="box">
	<div class="body">
		<div class="panes">
			<div class="clearfix">
				<table cellpadding="0" cellspacing="0" border="0" class="display dataTable">
					<thead>
						<tr>
							<th>
								<div>
									<input name="checkAll" id = "checkAll" onclick="checkAllList(this);" type="checkbox" >
								</div>
							</th>
							<th>ID</th>																					
							<th>Họ tên</th>
							<th>Email</th>														
							<th>Ngày sinh</th>							
							<th>Địa chỉ</th>							
							<th>Số điện thoại</th>
							<th>Giới tính</th>							
							<th>Loại</th>
							<th>Ảnh đại diện</th>
							<th>Thao tác</th>
						</tr>
					</thead>
					<tbody>
						<{foreach from=$UserEntities item=item name=UserEntities}>
						<tr class="gradeX">
							<td>
								<div>
									<input name="checkItem<{$i}>" id="checkItem<{$i}>" value="<{$UserEntity->id}>" type="checkbox">
								</div>
							</td>
							<td><{$item->id}></td>							
							<td><{$item->fullname}></td>
							<td><{$item->email}></td>
							<td><{$item->birthday}></td>
							<td><{$item->address}></td>
							<td><{$item->phone}></td>
							<td><{$item->gender}></td>
							<td><{$item->getUserTypeName()}></td>
							<td><img style="max-height: 50px; max-width: 50px;" src="<{$item->getImage()}>"></td>						
														
							<td valign="middle">
								<div style="float: right;">
									<a href="javascript:void(0);" title="Login to User's Panel" onclick="if (confirm('Are you sure you want to log into this User panel?')) { loginUserAction(<{$UserEntity->id}>); } else { return false; }" class="notboldText">
										<img src="<{$APPLICATION_URL}>/Themes/Default/Images/login_icon.gif" alt="Login to User's Panel" width="16" />
									</a>
									<a href="javascript:void(0);" title="Resend Password" onclick="if (confirm('Are you sure you want to resend password to this user?')) { resendPassAction(<{$item->id}>); } else { return false; }  " class="notboldText">
										<img src="<{$APPLICATION_URL}>/Themes/Default/Images/resend.png" alt="Resend Password" width="16" />
									</a>
									<a href="<{$APPLICATION_URL}>/Admin/User/edit/id/<{$item->id}>" title="Edit this item">
										<img src="<{$APPLICATION_URL}>/Themes/Default/Images/b_edit.png" alt="" />
									</a>
									<a href="javascript:void(0);" title="Delete this item" onclick="if (confirm('Are you sure you want to delete this user')) { deleteAction(<{$UserEntity->id}>); } else { return false; }" class="notboldText">
										<img src="<{$APPLICATION_URL}>/Themes/Default/Images/b_drop.png" alt="" />
									</a>
									
								</div>
							</td>
						</tr>
						<{/foreach}>						
					</tbody>
					<tr>
						
					</tr>
				</table>
			</div>
			
		</div>
	</div>
</div>
<input type="hidden" name="iCount" id="iCount" value="<{$i}>" />
<input type="hidden" name="idValue" id="idValue" value="" />
<input type="hidden" id="actionForm" name="actionForm" value="">
<input type="hidden" id="actionKey" name="actionKey" value="<{$actionKey}>">
</form>